{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="javascript:history.back()"><i class="return"></i></a>
	<div class="titleView-x">登录</div>
</div>

<div class="main-top login-index">
	<form action="wap.php?app=passport&act=login" method="post">
	<input type="hidden" name="gourl" value="{$url}" />
	<input type="hidden" name="nick_name" value="{$data.nick_name}" />
	<input type="hidden" name="sex" value="{$data.sex}" />
	<input type="hidden" name="avatar" value="{$data.avatar}" />
	<input type="hidden" name="province" value="{$data.province}" />
	<input type="hidden" name="city" value="{$data.city}" />
	<input type="hidden" name="openid" value="{$data.openid}" />
	<ul>
		<li><input type="tel" name="mobile" id="mobile" placeholder="手机号" /></li>
		<li class="code"><a href="javascript:void(0)">获取验证码</a><input type="tel" name="code" id="code" placeholder="验证码" /></li>
		<li><input type="tel" name="invite_code" id="invite_code" placeholder="邀请码(选填)" /></li>
	</ul>
	</form>
	
	<div class="buttonView">
		<a href="javascript:void(0)" class="btn">登录</a>
	</div>
</div>

{include file="footer.html"}
<script>
var _mobileText = '', _codeText = '', _getCode = false, _count = 0, _timer = null;
$(function(){
	$('.code a').click(function(){
		if(_getCode)return false;
		if(!$('#mobile').val().length){
			alert('请输入手机号');
			return;
		}
		var _this = $(this);
		_getCode = true;
		_mobileText = '';
		_codeText = '';
		$.postJSON('api.php?app=passport&act=send_sms', { mobile:$('#mobile').val() }, function(json){
			_mobileText = json.data.mobile;
			_codeText = json.data.code;
			_count = 60;
			_timer = setInterval(function(){
				_count--;
				if (_count<=0) {
					clearInterval(_timer);
					_timer = null;
					_getCode = false;
					_this.removeClass('disabled').html('获取验证码');
				} else {
					_this.addClass('disabled').html(_count+'s后可重发');
				}
			}, 1000);
		});
	});
	$('.buttonView .btn').click(function(){
		if(!$('#mobile').val().length){
			alert('请输入手机号');
			return;
		}
		if(!$('#code').val().length){
			alert('请输入验证码');
			return;
		}
		if($('#mobile').val()!=_mobileText){
			alert('手机号码不正确');
			return;
		}
		if($('#code').val()!=_codeText){
			alert('验证码不正确');
			return;
		}
		$('form').submit();
	});
});
</script>